/*
 * Copyright 2002-2023 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.aop;

import org.aopalliance.aop.Advice;

/**
 * Advisor 主要是判断验证 advice，并把advice 应用于特定的目标对象。
 * <br>
 * Base interface holding AOP <b>advice</b> (action to take at a joinpoint)
 * and a filter determining the applicability of the advice (such as
 * a pointcut). <i>This interface is not for use by Spring users, but to
 * allow for commonality in support for different types of advice.</i>
 *<p> 基础接口，用于持有AOP <b>advice</b>（执行的动作）和<b>filter</b>，用于确定advice的可应用性（如切入点）。
 * <i>此接口不是Spring用户使用的，而是为了支持不同类型的advice。</i>
 *
 * <p>Spring AOP is based around <b>around advice</b> delivered via method
 * <b>interception</b>, compliant with the AOP Alliance interception API.
 * The Advisor interface allows support for different types of advice,
 * such as <b>before</b> and <b>after</b> advice, which need not be
 * implemented using interception.
 * <br> Spring AOP 基于通过方法<b>拦截</b>传递的 <b>环绕advice</b>，符合AOP Alliance 拦截API。
 * Advisor接口允许支持不同类型的advice，如<b>before</b>和<b>after</b> advice，这些不需要使用拦截来实现。
 * <p>通常情况下，Spring AOP 用户不需要直接使用此接口。
 *
 * <p>
 * An Advisor combines advice with a pointcut expression or other information to specify exactly where the advice should be applied.
 * In Spring AOP, advisors can be more complex than simple advice
 * because they encapsulate both the logic of what to do and the criteria for when to do it.
 * <br> Advisor结合advice和切入点表达式或其他信息，以精确指定何时应用advice。
 * 在Spring AOP中，advisors可以比简单的advice更复杂，因为它们封装了要做什么和何时做的逻辑。
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 */
public interface Advisor {

	/**
	 * Common placeholder for an empty {@code Advice} to be returned from
	 * {@link #getAdvice()} if no proper advice has been configured (yet).
	 * @since 5.0
	 */
	Advice EMPTY_ADVICE = new Advice() {};


	/**
	 * Return the advice part of this aspect. An advice may be an
	 * interceptor, a before advice, a throws advice, etc.
	 * @return the advice that should apply if the pointcut matches
	 * @see org.aopalliance.intercept.MethodInterceptor
	 * @see BeforeAdvice
	 * @see ThrowsAdvice
	 * @see AfterReturningAdvice
	 */
	Advice getAdvice();

	/**
	 * Return whether this advice is associated with a particular instance
	 * (for example, creating a mixin) or shared with all instances of
	 * the advised class obtained from the same Spring bean factory.
	 * <br> 返回 此advice是否与特定实例相关（例如，创建mixin）或共享所有从同一Spring bean工厂获取的advised class实例。
	 * （advised class实例 通常是一个 bean工厂？ ）
	 * <p><b>Note that this method is not currently used by the framework.</b>
	 * Typical Advisor implementations always return {@code true}.
	 * Use singleton/prototype bean definitions or appropriate programmatic
	 * proxy creation to ensure that Advisors have the correct lifecycle model.
	 * <p>As of 6.0.10, the default implementation returns {@code true}.
	 * @return whether this advice is associated with a particular target instance
	 */
	default boolean isPerInstance() {
		return true;
	}

}
